#include<iostream>
#include<string>
#include<pthread.h>
#include<unistd.h>
using std::cout;
using std::endl;
using std::string;
void TidPrint(const char* str,const pthread_t tid)
{
    cout<<"Thread Name::"<<str<<"ID::"<<tid<<endl;
}
void* tidFun(void* agrc)
{
    char* str=(char*)agrc;
    int count=5;
    while(count)
    {
        TidPrint(str,pthread_self());
        sleep(1);
        count--;
    }
    cout<<"thread is over!"<<endl;

    int *ret=new int(123);
    return (void*)ret;
}
int main()
{
    pthread_t tid;
    pthread_create(&tid,nullptr,tidFun,(void*)"I am thread!");
    sleep(15);

    void* ret=nullptr;
    pthread_join(tid,&ret);
    cout<<"Main thread has joined thread1,ready to print tread ret"<<endl;

    sleep(2);
    cout<<"print thread ret::"<<*((int*)ret)<<endl;
    delete (int*)ret;
    return 0;
}
